
package carmadness;

import carmadness.model.*;
import carmadness.controller.*;
import carmadness.view.*;

/**
 * A Game osztály.
 * 
 * @author Szelei
 * @version 1.0
 * @created 10-Apr-2010 2:32:39 PM
 */
public class Game
{
	private GameState _state;
	private Controller _controller;
	private static Game _instance;

	public static Game getInstance() 
	{
		if ( _instance == null ) _instance = new Game();

		return _instance; 
	}

	public static void main( String[] args )
	{
		getInstance().init();
	}

	/**
	 * Inicializálás
	 */
	public void init()
	{
		Renderer.registerRenderer( Bank.class, new ConsoleBankRenderer() );
		Renderer.registerRenderer( Bunny.class, new ConsoleBunnyRenderer() );
		Renderer.registerRenderer( Civilian.class, new ConsoleCivilianRenderer() );
		Renderer.registerRenderer( HideOut.class, new ConsoleHideOutRenderer() );
		Renderer.registerRenderer( Police.class, new ConsolePoliceRenderer() );
		Renderer.registerRenderer( Robber.class, new ConsoleRobberRenderer() );
		Renderer.registerRenderer( RoadSegment.class, new ConsoleRSRenderer() );
		Renderer.registerRenderer( SourceRoadSegment.class, new ConsoleSourceRSRenderer() );
		Renderer.registerRenderer( DrainRoadSegment.class, new ConsoleDrainRSRenderer() );
		Renderer.registerRenderer( PoliceStation.class, new ConsolePoliceStationRenderer() );
		Renderer.registerRenderer( Grass.class, new ConsoleGrassRenderer() );
		Renderer.registerRenderer( IncomingRoadSegmentWrapper.class, new ConsoleIncomingRSWRenderer() );
		Renderer.registerRenderer( OutgoingRoadSegmentWrapper.class, new ConsoleOutgoingRSWRenderer() );
		Renderer.registerRenderer( StopSign.class, new ConsoleStopSignRenderer() );
		Renderer.registerRenderer( TrafficLight.class, new ConsoleTrafficLightRenderer() );
		Renderer.registerRenderer( SpeedLimit.class, new ConsoleSpeedLimitRenderer() );
		Renderer.registerRenderer( Grass.class, new ConsoleGrassRenderer() );
		Renderer.registerRenderer( Game.class, new ConsoleGameRenderer() );

		getInstance()._state = GameState.Playing;

		_controller = new ConsoleController();
	}

	/**
	 * Get _state.
	 * 
	 * @return _state as GameState.
	 */
	public GameState getState()
	{
		return _state;
	}

	/**
	 * Set _state.
	 * 
	 * @param _state
	 *            the value to set.
	 */
	public void setState( GameState state )
	{
		this._state = state;
	}
}
